/*
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * RSCollada.h
 *
 *  Created on: 2010/02/16
 *      Author: Alexandre Pires ( c.alexandre.pires@gmail.com )
 */

#ifndef RSCOLLADA_H_
#define RSCOLLADA_H_

#include "RSElement.h"

namespace Realsphere {

    class RSDocument: public Realsphere::RSElement {
        Q_OBJECT
        Q_PROPERTY( QString _attr_xmlns READ XmlNS WRITE SetXmlNS )
        Q_PROPERTY( QString _attr_base READ Base WRITE SetBase )
        public:
            Q_INVOKABLE RSDocument ( const QString& rXmlNS = RS_COLLADA_XMLNS );
            virtual ~RSDocument();

            QString                         XmlNS () const;
            QString                         Base () const;
            RSScene*                        Scene () const;
            RSDataSource*                   GetDataSource ( const QString& rId );

            RSGeometriesLibrary*            GetGeometriesLibrary ( unsigned int rIndex ) const;
            RSGeometriesLibrary*            GetGeometriesLibrary ( const QString& rId ) const;
            int                             IndexOf ( RSGeometriesLibrary* rGeometriesLibrary );
            unsigned int                    GeometriesLibrariesSize ();
            RSGeometriesLibraries           GeometriesLibraries () const;
            RSGeometriesLibrariesIterator   GeometriesLibrariesIterator () const;

            RSVisualScenesLibrary*          GetVisualScenesLibrary ( unsigned int rIndex ) const;
            RSVisualScenesLibrary*          GetVisualScenesLibrary ( const QString& rId ) const;
            int                             IndexOf ( RSVisualScenesLibrary* rVisualScenesLibrary );
            unsigned int                    VisualScenesLibrariesSize ();
            RSVisualScenesLibraries         VisualScenesLibraries () const;
            RSVisualScenesLibrariesIterator VisualScenesLibrariesIterator () const;

            RSCamerasLibrary*               GetCamerasLibrary ( unsigned int rIndex ) const;
            RSCamerasLibrary*               GetCamerasLibrary ( const QString& rId ) const;
            int                             IndexOf ( RSCamerasLibrary* rCamerasLibrary );
            unsigned int                    CamerasLibrariesSize ();
            RSCamerasLibraries              CamerasLibraries () const;
            RSCamerasLibrariesIterator      CamerasLibrariesIterator () const;

            bool                            IsRootElement () const;

        public slots:
            void                            SetXmlNS ( const QString& rXmlNS );
            void                            SetBase ( const QString& rBase );

            RSError                         AddGeometriesLibrary ( RSGeometriesLibrary* rLibrary );
            RSError                         RemoveGeometriesLibrary ( RSGeometriesLibrary* rLibrary );
            RSError                         RemoveGeometriesLibrary ( const QString& rId );
            RSError                         RemoveGeometriesLibrary ( unsigned int rIndex );

            RSError                         AddVisualScenesLibrary ( RSVisualScenesLibrary* rLibrary );
            RSError                         RemoveVisualScenesLibrary ( RSVisualScenesLibrary* rLibrary );
            RSError                         RemoveVisualScenesLibrary ( const QString& rId );
            RSError                         RemoveVisualScenesLibrary ( unsigned int rIndex );

            RSError                         AddCamerasLibrary ( RSCamerasLibrary* rLibrary );
            RSError                         RemoveCamerasLibrary ( RSCamerasLibrary* rLibrary );
            RSError                         RemoveCamerasLibrary ( const QString& rId );
            RSError                         RemoveCamerasLibrary ( unsigned int rIndex );

            RSError                         SetScene ( RSScene* rScene );

        signals:
            void                            XmlNSChanged ( const QString& rXmlNS );
            void                            BaseChanged ( const QString& rBase );

            void                            GeometriesLibraryAdded ( RSDocument* rDocument, RSGeometriesLibrary* rLibrary );
            void                            GeometriesLibraryRemoved ( RSDocument* rDocument, RSGeometriesLibrary* rLibrary );

            void                            VisualScenesLibraryAdded ( RSDocument* rDocument, RSVisualScenesLibrary* rLibrary );
            void                            VisualScenesLibraryRemoved ( RSDocument* rDocument, RSVisualScenesLibrary* rLibrary );

            void                            CamerasLibraryAdded ( RSDocument* rDocument, RSCamerasLibrary* rLibrary );
            void                            CamerasLibraryRemoved ( RSDocument* rDocument, RSCamerasLibrary* rLibrary );

            void                            SceneChanged ( RSDocument* rDocument, RSScene* rScene );

        protected:
            RSError                         BeforeAddChildElement ( RSElement* rChild );
            bool                            AfterAddChildElement ( RSElement* rChild );
            bool                            AfterRemoveChildElement ( RSElement* rChild );

        private:
            QString                         mXmlNS;
            QString                         mBase;
            RSGeometriesLibraries           mGeometriesLibraries;
            RSVisualScenesLibraries         mVisualScenesLibraries;
            RSCamerasLibraries              mCamerasLibraries;
            RSScene*                        mScene;
    };

}

#endif /* RSCOLLADA_H_ */
